<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>5秒后跳转页面</title>
  </head>
  <body>
    <div></div>

    <script>
      var divEle = document.querySelector('div');
      var time = 5;

      // 处理页面空白问题
      jump();

      setInterval(function () {
        jump();
      }, 1000);

      function jump() {
        if (time === 0) {
          window.location.href = 'https://www.itcast.cn';
        } else {
          divEle.innerHTML = time + '秒后跳转到传智教育首页';
          time--;
        }
      }
    </script>
  </body>
</html>
